package com.hdu.dwh.service;

import com.hdu.dwh.dtos.TablePageDto;
import com.hdu.dwh.pojos.PaimonTag;
import com.hdu.dwh.pojos.source_access_pojos.DataWarehouseDatabase;
import com.hdu.dwh.pojos.source_access_pojos.DataWarehouseTable;
import com.hdu.dwh.pojos.source_access_pojos.IColumn;
import com.hdu.dwh.dtos.DataWarehouseTableDto;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hdu.dwh.vos.TreeVo;
import com.hdu.dwh.vos.dataWareHouse_vos.DataWarehouseTableDetailVo;
import com.hdu.dwh.results.ResponseResult;

import java.sql.SQLException;
import java.util.List;
import java.util.Set;

/**
 * <p>
 * 源数据表表 服务类
 * </p>
 *
 * @author bobo
 * @since 2025-04-08
 */
public interface DataWarehouseTableService extends IService<DataWarehouseTable> {

    ResponseResult add(DataWarehouseTableDto sourceTableDto);

    boolean existsByIds(List<Long> sourceTableIds);

    DataWarehouseTableDetailVo getDetilById(Long id) throws Exception;

    long countTablesByDataType(Integer dataType);

    long countTablesByHierarchy(Integer hierarchy);

    ResponseResult detilPage(TablePageDto assetDetilDto);

    TreeVo tree();

    ResponseResult getTable(Long databaseId, String databaseName, Integer hierarchy);

    DataWarehouseTable queryByNameAndDatabaseId(String sourceTable, String targetTable, Long id);

    void deleteByTargetDatabaseName(String dbName);

    void removeByDatabase(DataWarehouseDatabase byDatabaseName);

    void addTag(DataWarehouseTable table, String tag);

    void deleteTag(DataWarehouseTable table, String tag);

    Set<PaimonTag> fetchTags(DataWarehouseTable table);

    void rollBackToTag(DataWarehouseTable table, String tag);

    Set<DataWarehouseTable> traceUp(DataWarehouseTable table);

    Set<DataWarehouseTable> traceDown(DataWarehouseTable table);

    DataWarehouseTable createTable(Long targetDatabaseId, String targetTable, Long sourceTableId, Integer hierarchy,
            String description);

    Boolean checkTableNameExist(Long id, String saveTableName);

    void deleteTable(DataWarehouseTable table);

    void deleteTable(Long tableId);

    DataWarehouseTable createTable(Long targetDatabaseId, String targetTable, Long sourceTableId, Integer hierarchy,
            String description, Set<IColumn> columns);

    DataWarehouseTable getPaimonTableByDatabaseAndTableName(String database, String table);

}